﻿@{ 
    
}
@model  DataAccess.Models.AgencyUsers

<script src="~/Scripts/plugins/jquery.min.js"></script>
<script src="~/Scripts/plugins/layer/layer.min.js"></script>
<script src="~/Scripts/plugins/iCheck/icheck.min.js"></script>


@section Scripts{
    <script src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Scripts/plugins/validate/messages_zh.min.js"></script>

    <script src="~/Scripts/sys/lib/common_raw.js"></script>

    <script type="text/javascript">
        var index = parent.layer.getFrameIndex(window.name);

        $(function () {
            $("#cancel").click(function () {
                parent.location.reload();
                parent.layer.close(index);
            });

            $.validator.setDefaults({
                submitHandler: function () { 
                    var startH = $("select[name=starH]");
                    var startM = $("select[name=starM]");
                    var endH = $("select[name=endH]");
                    var endM = $("select[name=endM]");

                    if (startH.length != startM.length || startH.length != endH.length || startH.length != endM.length)
                    {
                        common.msg("数据错误,请刷新页面", 2);
                        return false;
                    }

                    var startHstr = "",startMstr = "",endHstr = "",endMstr = "";
                    for (var i = 0; i < startH.length; i++) {
                        if (startHstr == "") { startHstr += $(startH[i]).val(); } else { startHstr += ","; startHstr += $(startH[i]).val() }
                        if (startMstr == "") { startMstr += $(startM[i]).val(); } else { startMstr += ","; startMstr += $(startM[i]).val() }
                        if (endHstr == "") { endHstr += $(endH[i]).val(); } else { endHstr += ","; endHstr += $(endH[i]).val() }
                        if (endMstr == "") { endMstr += $(endM[i]).val(); } else { endMstr += ","; endMstr += $(endM[i]).val() }
                    }

                   
                    common.invokeApi(
                    "post",
                    "/robotAgencyUser.html",
                    {
                        id: $("#id").val(), send_interval: $("#send_interval").val(), send_removal: $("#send_removal").val(),
                        startHstr:startHstr,startMstr:startMstr,endHstr:endHstr,endMstr:endMstr
                    },
                    function () { },
                    function (data) {
                        common.msg(data.Message, 1, function ()
                        {
                            
                        });
                    },
                    function (data) {
                        common.msg(data.Message, 2);
                    },
                    function () { }
                    );
                }
            });

            $("#form1").validate({
                rules: {
                    send_interval: {
                        required: true,
                        digits: true,
                        range: [300, 1200],
                    }
                },
                messages: {
                    group_name: "必须输入群名称,且不能大于50个字符"
                }
            });
        });
    </script>
}

    <div class="row">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-lg-12">
                    <ol class="breadcrumb">
                        <li><a href="#">系统管理</a></li>
                        <li class="active"><span>阿里妈妈联盟账号</span></li>
                    </ol>
                    <h1>新增修改阿里妈妈联盟账号</h1>
                </div>
            </div>
            <div class="row">
                <div class="main-box clearfix">
                    <div class="main-box-body clearfix">
                        <div class="table-responsive">

                            <table class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>
                                            账号：@Model.username
                                        </th>
                                        <th>
                                            姓名：@Model.nickname
                                        </th>
                                        <th>
                                            手机：@Model.tel
                                        </th>
                                    </tr>
                                    <tr>
                                        <th>
                                            状态：@(Model.state == 1 ? "启用" : "禁用")
                                        </th>
                                        <th id="promotion">
                                            代理：@(Model.promotion == 1 ? "开启" : "未开启")
                                        </th>
                                        <th>
                                            备注：@Model.remark
                                        </th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                        @{
                            if (Model.promotion == 1)
                            {<div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>网站PID：@(Model.site_pid)</th>
                                    <th>QQPID：@(Model.qq_pid)</th>
                                    <th>微信PID：@(Model.wechat_pid)</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                            }
                        }
                    </div>




                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-content">
                                <form method="post" class="form-horizontal" id="form1">
                                    <input type="hidden" id="id" name="id" value="@(Model.id)" />
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">发单间隔<span style="color:red;">(秒)</span>:</label>
                                        <div class="col-sm-3">
                                            <input type="text" id="send_interval" name="send_interval" value="@(Model.send_interval)" class="form-control" placeholder="输入发单间隔">
                                        </div>
                                        <label class="col-sm-2 control-label">发单去重：</label>
                                        <div class="col-sm-3">
                                            <select class="form-control" name="send_removal" id="send_removal">
                                                <option value="0">不去重</option>
                                                <option value="1">去重</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">时间段<span style="color:red;">(*)</span>：</label>
                                        <div class="col-sm-8">
                                            <table style="width:100%;">
                                                <thead>
                                                    <tr>
                                                        <th>
                                                            <select class="form-control" id="stage11" name="starH">
                                                                @{
                                                                if (Model.send_stageArr.Count > 0)
                                                                {
                                                                    TimeSpan ts11 = TimeSpan.Parse(Model.send_stageArr[0].Split('-')[0]);

                                                                    for (int i = 0; i < 24; i++)
                                                                    {

                                                                        if (ts11.Hours == i)
                                                                        {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                        }
                                                                        else
                                                                        {
                                                            <option value="@(i)">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                        }
                                                                    }
                                                                }

                                                                }
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select class="form-control" id="stage12" name="starM">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts11 = TimeSpan.Parse(Model.send_stageArr[0].Split('-')[0]);
                                                                for (int i = 0; i < 59; i++)
                                                                {
                                                                    if (ts11.Minutes == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th style="width:50px;text-align:center;">&nbsp;&nbsp;至&nbsp;&nbsp;</th>
                                                        <th>
                                                            <select class="form-control" id="stage13" name="endH">
                                                                @{
                                                                if (Model.send_stageArr.Count > 0)
                                                                {
                                                                    TimeSpan ts12 = TimeSpan.Parse(Model.send_stageArr[0].Split('-')[1]);

                                                                    for (int i = 0; i < 24; i++)
                                                                    {

                                                                        if (ts12.Hours == i)
                                                                        {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                        }
                                                                        else
                                                                        {
                                                            <option value="@(i)">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                        }
                                                                    }
                                                                }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select class="form-control" id="stage14" name="endM">
                                                                @{  if (Model.send_stageArr.Count > 0)
                                                              {
                                                                  TimeSpan ts12 = TimeSpan.Parse(Model.send_stageArr[0].Split('-')[1]);
                                                                  for (int i = 0; i < 59; i++)
                                                                  {

                                                                      if (ts12.Minutes == i)
                                                                      {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                      }
                                                                      else
                                                                      {
                                                            <option value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                      }
                                                                  }
                                                              }
                                                                }
                                                            </select>
                                                        </th>
                                                    </tr>
                                                    <tr>
                                                        <th>&nbsp;</th>
                                                    </tr>
                                                    <tr>
                                                        <th>
                                                            <select class="form-control" id="stage21" name="starH">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts21 = TimeSpan.Parse(Model.send_stageArr[1].Split('-')[0]);

                                                                for (int i = 0; i < 24; i++)
                                                                {

                                                                    if (ts21.Hours == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i)">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select class="form-control" id="stage22" name="starM">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts21 = TimeSpan.Parse(Model.send_stageArr[1].Split('-')[0]);
                                                                for (int i = 0; i < 59; i++)
                                                                {

                                                                    if (ts21.Minutes == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th style="width:50px;text-align:center;">&nbsp;&nbsp;至&nbsp;&nbsp;</th>
                                                        <th>
                                                            <select class="form-control" id="stage23" name="endH">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts22 = TimeSpan.Parse(Model.send_stageArr[1].Split('-')[1]);

                                                                for (int i = 0; i < 24; i++)
                                                                {

                                                                    if (ts22.Hours == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i)">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select class="form-control" id="stage24" name="endM">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts22 = TimeSpan.Parse(Model.send_stageArr[1].Split('-')[1]);
                                                                for (int i = 0; i < 59; i++)
                                                                {
                                                                    if (ts22.Minutes == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                    </tr>
                                                    <tr>
                                                        <th>&nbsp;</th>
                                                    </tr>
                                                    <tr>
                                                        <th>
                                                            <select class="form-control" id="stage31" name="starH">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts31 = TimeSpan.Parse(Model.send_stageArr[2].Split('-')[0]);

                                                                for (int i = 0; i < 24; i++)
                                                                {

                                                                    if (ts31.Hours == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i)">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select class="form-control" id="stage32" name="starM">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts31 = TimeSpan.Parse(Model.send_stageArr[2].Split('-')[0]);
                                                                for (int i = 0; i < 59; i++)
                                                                {

                                                                    if (ts31.Minutes == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                        <th style="width:50px;text-align:center;">&nbsp;&nbsp;至&nbsp;&nbsp;</th>
                                                        <th>
                                                            <select class="form-control" id="stage33" name="endH">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts32 = TimeSpan.Parse(Model.send_stageArr[2].Split('-')[1]);

                                                                for (int i = 0; i < 24; i++)
                                                                {

                                                                    if (ts32.Hours == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i)">@(i.ToString().PadLeft(2, '0')) 时</option>
                                                                    }
                                                                }
                                                            }
                                                                }

                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select class="form-control" id="stage34" name="endM">
                                                                @{if (Model.send_stageArr.Count > 0)
                                                            {
                                                                TimeSpan ts32 = TimeSpan.Parse(Model.send_stageArr[2].Split('-')[1]);
                                                                for (int i = 0; i < 59; i++)
                                                                {

                                                                    if (ts32.Minutes == i)
                                                                    {
                                                            <option selected value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                    else
                                                                    {
                                                            <option value="@(i.ToString().PadLeft(2, '0'))">@(i.ToString().PadLeft(2, '0')) 分</option>
                                                                    }
                                                                }
                                                            }
                                                                }
                                                            </select>
                                                        </th>
                                                    </tr>
                                                </thead>
                                            </table>
                                        </div>
                                    </div>
                                    <div class="hr-line-dashed"></div>
                                    <div class="form-group" style="text-align:center;">
                                        <button class="btn btn-primary" id="submit" type="submit">保存设置</button>
                                        
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            </div>
                
            </div>



